﻿// /************************************************************************/
// /*@Company           :
// /*@Author            :
// /*@FrameWork         : NET8
// /*@Company Web       :
// /*@Description       :
// /************************************************************************/

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Neto.Core.CoreServices;

public interface ISysFileService
{
    /// <summary>
    ///     判断是不是tif
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    bool IsTifImage(string filePath);


    /// <summary>
    ///     tif转化为png
    /// </summary>
    /// <param name="inputPath"></param>
    /// <param name="outputPath"></param>
    Task ConvertTifToPng(string inputPath, string outputPath);


    /// <summary>
    ///     tif转换为jpg
    /// </summary>
    /// <param name="inputPath"></param>
    /// <param name="outputPath"></param>
    Task ConvertTifToJpg(string inputPath, string outputPath);

    /// <summary>
    ///     图片转换为webp
    /// </summary>
    /// <param name="inputPath"></param>
    /// <param name="outputPath"></param>
    Task ConvertTifToWebP(string inputPath, string outputPath);

    #region 旧版本文件上传

    ///// <summary>
    ///// 上传文件
    ///// </summary>
    ///// <param name="webUploadInput"></param>
    ///// <returns></returns>
    //Task<WebUploadResult> Upload(WebUploadInput webUploadInput = null);

    ///// <summary>
    ///// 添加文件
    ///// </summary>
    ///// <param name="webUploadInput"></param>
    ///// <param name="webUploadResult"></param>
    ///// <returns></returns>
    //Task<SysFiles> InsertFile(WebUploadInput webUploadInput, WebUploadResult webUploadResult);

    ///// <summary>
    ///// 获取文件
    ///// </summary>
    ///// <param name="FId"></param>
    ///// <param name="isOpen">是否限制开放文件</param>
    ///// <returns></returns>
    //Task<FileResult> GetFile_old(string FId, bool? isOpen);

    #endregion

    #region 新版本文件上传

    /// <summary>
    ///     获取默认图片上传设置
    ///     允许上传的扩展：.jpg .png .jpeg .jif .bmp .webp
    ///     RelFileFloder=category
    /// </summary>
    /// <param name="category">分类</param>
    /// <param name="isOpen">是否公开</param>
    /// <param name="relRoutUrl">相对路径:默认f</param>
    /// <returns></returns>
    FileUploadSetting GetDefaultImageSetting(string category, bool isOpen = false, string relRoutUrl = "f");

    /// <summary>
    ///     获取默认富文本上传设置
    ///     允许上传的扩展：.jpg .png .jpeg .jif .bmp .webp .pdf .doc .docx .xls .xlsx .ppt .pptx .zip .rar
    ///     RelFileFloder=category
    /// </summary>
    /// <param name="category">分类</param>
    /// <param name="isOpen">是否公开</param>
    /// <param name="relRoutUrl">相对路径:默认f</param>
    /// <returns></returns>
    FileUploadSetting GetDefaultRichtextSetting(string category, bool isOpen = false, string relRoutUrl = "f");


    /// <summary>
    ///     上传单个文件。但是不保存到数据库
    /// </summary>
    /// <param name="fileUploadSetting"></param>
    /// <param name="file">要上传的文件，可选参数，默认为null。</param>
    /// <returns>返回上传结果。</returns>
    Task<WebUploadResult> GetUploadFile(FileUploadSetting fileUploadSetting, IFormFile file = null);

    /// <summary>
    ///     上传单个文件。
    /// </summary>
    /// <param name="fileUploadSetting">上传配置信息。</param>
    /// <param name="file">要上传的文件，可选参数，默认为null。</param>
    /// <returns>返回上传结果。</returns>
    Task<WebUploadResult> UploadFile(FileUploadSetting fileUploadSetting, IFormFile? file = null);

    /// <summary>
    ///     上传多个文件。
    /// </summary>
    /// <param name="fileUploadSetting">上传配置信息。</param>
    /// <param name="files">要上传的文件列表，可选参数，默认为null。</param>
    /// <returns>返回上传结果列表。</returns>
    Task<List<WebUploadResult>> UploadFiles(FileUploadSetting fileUploadSetting, List<IFormFile?>? files = null);

    /// <summary>
    ///     根据文件ID异步获取文件，支持获取缩略图和指定文件是否公开。
    /// </summary>
    /// <param name="fid">文件ID</param>
    /// <param name="isThumbnail">是否获取缩略图</param>
    /// <param name="isOpen">是否公开的标志（可选）</param>
    /// <returns>返回文件内容结果，如果文件不存在或查询失败，则返回404内容。</returns>
    Task<IActionResult> GetFile(string fid, bool? isThumbnail = null, bool? isOpen = null);


    /// <summary>
    ///     根据文件ID获取文件名。
    /// </summary>
    /// <param name="fid">文件ID</param>
    /// <returns>获取文件名</returns>
    Task<string> GetSysFileName(string fid);

    #endregion
}